package com.zhen.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class DataBindingController {

    public static final Log LOGGER = LogFactory.getLog(DataBindingController.class);

    @RequestMapping("/pathVariableTest/{userId}")
    public void pathVariableTest(@PathVariable Integer userId){
        LOGGER.info("通过@PathVariable获得数据：" + userId);
    }

    @RequestMapping("/requestHeaderTest")
    public void requestHeaderTest(@RequestHeader("User-Agent") String userAgent,@RequestHeader("Accept") String[] accepts){
        LOGGER.info("通过@RequestHeader获得数据：" + userAgent);
        for(String accept : accepts){
            LOGGER.info(accept);
        }

    }

    @RequestMapping("/cookieValueTest")
    public void cookieValueTest(@CookieValue("JSESSIONID") String sessionId){
        LOGGER.info("通过@CookieValue获得数据：" + sessionId);
    }

}
